

import axios from 'axios'

const $http = axios.create()
$http.install = function(Vue) {
    $http.interceptors.request.use(function(config) {
        if (config.url !== '/user/login') {
            const token = sessionStorage.getItem('token')
            const userId = sessionStorage.getItem('userId')
            const userRole = sessionStorage.getItem('userRole')
            config.headers.AuthUserToken = token
            config.headers.AuthUserRole = userRole
            config.headers.AuthUserId = userId
        }
        return config;
    }, function(error) {
        return Promise.reject(error);
    });
    $http.interceptors.response.use(function(response) {

        return response;
    }, function(error) {

        return Promise.reject(error);
    });
    Vue.prototype.$http = $http;
};
export default $http